package com.my.model.single;


public class Single {

    private static boolean flag=false;
    private Single(){
        if(flag==false){
            flag=!flag;
        }else{
            throw new RuntimeException("单例模式被侵犯了");
        }
    }


    public static Single getInstance(){
        return SingleImpl.instance;
    }
    private static class SingleImpl{
        private static final Single instance=new Single();
    }
}
